<template>
  <div class="rank-item">
    <div class="num-box">
      <img :src="num" alt="" />
      <div>{{ info.index }}</div>
    </div>
    <div class="rank-item1">
      <div class="rank-item1__top">
        <!-- <div class="dot"></div> -->
        <span class="name">{{ info.name }}</span>
        <span class="value">{{ info.value }}次</span>
      </div>
      <div class="rank-item1__bottom">
        <div
          class="progress"
          :style="{
            width: `${info.value}%`,
            'background-image': `linear-gradient(90deg, ${currentColor[0]} 3%,${currentColor[1]} 100%)`,
          }"
        ></div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { computed } from "vue";
import num from "@/assets/image/num.png";
const colors = [
  ["rgba(251, 218, 190, 0.8)", "rgba(204, 110, 38, 1)"],
  ["rgba(226, 255, 251, 0.8)", "rgba(38, 204, 182, 1)"],
  ["rgba(231, 246, 253, 0.8)", "rgba(17, 151, 205, 1)"],
  ["rgba(196, 216, 255, 0.8)", "rgba(54, 113, 232, 1)"],
  ["rgba(196, 216, 255, 0.8)", "rgba(54, 113, 232, 1)"],
];
const props = defineProps({
  info: {
    type: Object,
    default: () => {},
  },
});
const currentColor = computed(() => {
  return colors[0];
});
</script>

<style lang="scss" scoped>
.rank-item {
  padding: 0px 0px;
  font-size: 16px;
  color: #ffffff;
  display: flex;

  .num-box {
    width: 36px;
    height: 36px;
    margin-right: 10px;
    position: relative;

    img {
      width: 100%;
      height: 100%;
    }

    div {
      width: 36px;
      height: 36px;
      position: absolute;
      top: 0;
      left: 0;
      text-align: center;
      line-height: 36px;
    }
  }

  .rank-item1 {
    flex: 1;

    &__top {
      display: flex;
      align-items: center;

      .dot {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background-color: rgba(54, 113, 232, 1);
      }

      .rank {
        margin-left: 8px;
      }

      .name {
        flex: 1;
        width: 0px;
        margin: 0px 16px;
        text-overflow: ellipsis;
        overflow: hidden;
        word-break: break-all;
        white-space: nowrap;
      }

      .value {
        // width: 150px;
        text-align: right;
      }
    }

    &__bottom {
      margin-top: 8px;
      position: relative;
      background-color: rgba(92, 110, 130, 0.35);
      height: 8px;

      .progress {
        position: absolute;
        height: 100%;
        left: 0px;
        top: 0px;
      }
    }
  }
}

// .rank-item {
//   margin-bottom: 16px;
// }
</style>
